home *** CD-ROM | disk | FTP | other *** search
- /* main.cpp
- *
- * This is the actual core which makes this thing fly.
- */
-
- #include <string.h>
- #include <XApplication.h>
- #include <XWindow.h>
- #include <XDialog.h>
- #include <XStdControls.h>
- #include <XStdButtons.h>
- #include <XStdScroll.h>
- #include <XStdText.h>
-
- /************************************************************************/
- /* */
- /* The test */
- /* */
- /************************************************************************/
-
- /* MyProc
- *
- * Handle my procedure
- */
-
- static long MyProc(XGDialog *d, void *, long msg, long arg, void *c)
- {
- XGStdButton *b;
- XGStdText *t;
- char buffer[4];
- int v;
-
- if (msg == KEventButton) {
- if (arg == 1) {
- d->EndDialog(0);
- return 1;
- } else {
- b = (XGStdButton *)c;
- b->SetValue((b->GetValue()) ? 0 : 1);
- }
- } else if (msg == KEventScroll) {
- XGSScrollEvent *se;
- se = (XGSScrollEvent *)c;
- t = (XGStdText *)(d->FindViewByID(5));
- if (t) {
- v = se->scroll->GetValue();
-
- buffer[0] = (v / 100) + '0'; // cheap atol()
- buffer[1] = ((v / 10) % 10) + '0';
- buffer[2] = (v % 10) + '0';
- buffer[3] = 0;
-
- t->SetText(buffer);
- t->UpdateView();
- }
- }
- return 0;
- }
-
- /* DoTestModal
- *
- * Test my dialog creation/event loop stuff
- */
-
- static void DoTestModal(void)
- {
- XGDialog::ModalDialog(130,MyProc,NULL);
- }
-
- /* DoTestModeless
- *
- * Test my dialog creation/event loop stuff
- */
-
- static void DoTestModeless(void)
- {
- XGDialog::Create(130,MyProc,NULL);
- }
-
- /************************************************************************/
- /* */
- /* My app */
- /* */
- /************************************************************************/
-
- /* TMyApp
- *
- * My application
- */
-
- class TMyApp : public XGAppSingleWindow {
- public:
- TMyApp();
- virtual ~TMyApp();
- long ReceiveDispatch(long msg, long arg, void *parg);
- };
-
- /* TMyApp::TMyApp
- *
- * Create this
- */
-
- TMyApp::TMyApp()
- {
- XGInitStandardControls();
- }
-
- /* TMyApp::~TMyApp
- *
- * Create this
- */
-
- TMyApp::~TMyApp()
- {
- XGKillStandardControls();
- }
-
- /* TMyApp::ReceiveDispatch
- *
- * Do my test
- */
-
- long TMyApp::ReceiveDispatch(long msg, long arg, void *parg)
- {
- if (!IsModalWindow()) {
- if (msg == KEventDoMenuCommand) {
- if (arg == 100) {
- DoTestModal();
- return 1;
- }
- if (arg == 101) {
- DoTestModeless();
- return 1;
- }
- } else if (msg == KEventGetMenuStatus) {
- if ((arg == 101) || (arg == 100)) {
- ((XGSMenuStatusRecord *)parg)->enable = true;
- return 1;
- }
- }
- }
-
- return XGAppSingleWindow::ReceiveDispatch(msg,arg,parg);
- }
-
-
- /************************************************************************/
- /* */
- /* Main entry point */
- /* */
- /************************************************************************/
-
- /* StartApplication
- *
- * This starts up the application
- */
-
- XGAppCore *StartApplication(void)
- {
- XGAppSingleWindow *aw;
-
- /*
- * Start application engine
- */
-
- aw = new TMyApp;
-
- /*
- * Start window
- */
-
- XGWindow::Create(128);
-
- /*
- * Done. Return
- */
-
- return aw;
- }
-